package cmich.cps.scheduler.data;

import java.security.Timestamp;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Version;

import com.avaje.ebean.validation.NotNull;

/**
 * The Class Schedule.
 * 
 * @author Jonathan Kissinger <kissi1j@cmich.edu>
 */
@Entity
public class Schedule {
	
	/** The id. */
	@Id
	@GeneratedValue
	int id;
	
	/** The last update. */
	@Version
	Timestamp lastUpdate;
	
	/** The courses. */
	@OneToMany(fetch = FetchType.EAGER, cascade=CascadeType.ALL)
	private List<AssignedCourse> courses = new ArrayList<AssignedCourse>();
	
	/** The timestamp. */
	private String timestamp;
	
	/** The algorithm used. */
	@NotNull
	private String algorithmUsed;
	
	/** The value. */
	@NotNull
	private Integer value;
	
	/** The theoretical max. */
	private Integer theoreticalMax;

	/**
	 * Gets the id.
	 *
	 * @return the id
	 */
	public int getId() {
		return id;
	}

	/**
	 * Sets the id.
	 *
	 * @param id the new id
	 */
	public void setId(int id) {
		this.id = id;
	}

	/**
	 * Gets the last update.
	 *
	 * @return the last update
	 */
	public Timestamp getLastUpdate() {
		return lastUpdate;
	}

	/**
	 * Sets the last update.
	 *
	 * @param lastUpdate the new last update
	 */
	public void setLastUpdate(Timestamp lastUpdate) {
		this.lastUpdate = lastUpdate;
	}

	/**
	 * Gets the courses.
	 *
	 * @return the courses
	 */
	public List<AssignedCourse> getCourses() {
		return courses;
	}

	/**
	 * Sets the courses.
	 *
	 * @param courses the new courses
	 */
	public void setCourses(List<AssignedCourse> courses) {
		this.courses = courses;
	}

	/**
	 * Adds the course.
	 *
	 * @param course the course
	 */
	public void addCourse(AssignedCourse course) {
		this.courses.add(course);
	}

	/**
	 * Gets the algorithm used.
	 *
	 * @return the algorithm used
	 */
	public String getAlgorithmUsed() {
		return algorithmUsed;
	}

	/**
	 * Sets the algorithm used.
	 *
	 * @param algorithmUsed the new algorithm used
	 */
	public void setAlgorithmUsed(String algorithmUsed) {
		this.algorithmUsed = algorithmUsed;
	}

	/**
	 * Gets the value.
	 *
	 * @return the value
	 */
	public Integer getValue() {
		return value;
	}

	/**
	 * Sets the value.
	 *
	 * @param value the new value
	 */
	public void setValue(Integer value) {
		this.value = value;
	}
	
	/**
	 * Gets the timestamp.
	 *
	 * @return the timestamp
	 */
	public String getTimestamp() {
		return timestamp;
	}

	/**
	 * Sets the timestamp.
	 *
	 * @param timestamp the new timestamp
	 */
	public void setTimestamp(String timestamp) {
		this.timestamp = timestamp;
	}

	/**
	 * Gets the theoretical max.
	 *
	 * @return the theoretical max
	 */
	public Integer getTheoreticalMax() {
		return theoreticalMax;
	}

	/**
	 * Sets the theoretical max.
	 *
	 * @param theoreticalMax the new theoretical max
	 */
	public void setTheoreticalMax(Integer theoreticalMax) {
		this.theoreticalMax = theoreticalMax;
	}
}